<script setup lang="ts">
import { ref, watch, computed } from 'vue'
import { roleStore } from '@/stores/role'
import { headersStore } from '@/stores/apiHeader'
// 全球（4月）边际贡献额与边际贡献率
import GetMarginalAmoutRate from '@/components/PermissionsModule/Finance/components/GetMarginalAmoutRate.vue'
// 全球边际贡献额趋势
import MarginalContributionTrend from '@/components/PermissionsModule/Finance/components/MarginalAmountRateTrend.vue'
// 全球边际贡献率趋势
import MarginalRateTrend from '@/components/PermissionsModule/Finance/components/MarginalRateTrend.vue'
//  边际贡献额环比增长对比
import GetMarginalAmountMOMGrow from '@/components/PermissionsModule/Finance/components/GetMarginalAmountMOMGrow.vue'
// 全球边际贡献额同比增长情况
import MarginalContributionGrowth from '@/components/PermissionsModule/Finance/components/MarginalContributionGrowth.vue'
const store = roleStore() as any
const { financeLevel } = store

const rule = ref() // 1 普通 2 中级 3 高级
const info = () => {
  rule.value = financeLevel
}
info()
// 1 全球 2 区域 3 国家
const newRole = ref(0)
newRole.value = financeLevel // 初始化面板权限
//获取当前月份
const month = computed(() => {
  return headersStore().month
})
// 区分全球区域对比或国家对比  0各个区域，1 各个国家 默认空
const every_code = computed(() => {
  return headersStore().every_code
})
// 深度监听 store.panelPermissions
watch(
  () => store.financeLevel,
  (newVal) => {
    newRole.value = newVal
  }
)
const props = defineProps({
  showRemainingComponents: {
    type: Boolean,
    default: false,
  },
})
</script>

<template>
  <GetMarginalAmoutRate
    v-if="newRole != 0 && month !== '00' && every_code != ''"
  />
  <MarginalContributionTrend v-if="newRole != 0 && month == '00'" />
  <div v-if="showRemainingComponents">
    <MarginalContributionGrowth v-if="!(every_code == '' && month != '00')" />
    <GetMarginalAmountMOMGrow
      v-if="newRole != 0 && month !== '00' && every_code != ''"
    />
    <MarginalRateTrend v-if="newRole != 0 && month == '00'" />
  </div>
</template>
<style lang="scss" scoped></style>
